﻿#region 信息

// Copyright©2014 Rex Rao all rights reserved.
// File name : SoMcCoffee\Sohobloo.SoMcCoffee\EntityInfo.cs
// Author : Sohobloo
// Create time : 2014/02/05 1:35
// Update time : 2014/02/05 8:57

#endregion

#region 引用

using System;
using System.Collections.Generic;
using System.Reflection;
using Sohobloo.SoCommon.CommonExtension;

#endregion

namespace Sohobloo.SoMcCoffee.Entity
{
    public class EntityInfo
    {
        /// <summary>
        ///     获取 模型所在模块名称
        /// </summary>
        public string ModelName { get; private set; }

        /// <summary>
        ///     获取 模型名称
        /// </summary>
        public string Name { get; private set; }

        public IEnumerable<PropertyInfo> Properties { get; private set; }

        public EntityInfo(Type entityType)
        {
            var @namespace = entityType.Namespace;
            if(@namespace.IsNull())
            {
                return;
            }
            var index = @namespace.LastIndexOf('.') + 1;
            ModelName = @namespace.Substring(index, @namespace.Length - index);
            Name = entityType.Name;
            Properties = entityType.GetProperties();
        }
    }
}